<%@ page language="java" import="java.util.*,Bean.*" pageEncoding="UTF-8"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<!-- 引入 Bootstrap -->
      <link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 
      <!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
      <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
      <!--[if lt IE 9]>
         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      <![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">


<link rel="stylesheet"
	href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap-theme.min.css"></script>
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<!-- jquery表单前端验证 -->
<script
	src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script
	src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<title>教师界面</title>
</head>

<body  background="12.jpg" style="background-repeat:no-repeat;
		background-size:100%;
		backgroung-attachment:fixed;">
<div>
		  <a class="btn btn-info btn-sm" id="modal-24928" role="button" href="#modal-container-24928" data-toggle="modal" style="folat:right">添加</a>
  <table   width="1116" border="1"  class="table table-hover" id="myTable">
   
    <tr align="center">
      <td colspan="3">设置教师授课</td>
    </tr>
    <tr align="center">
      <td >任教编号</td>
      <td >教师</td>
      <td>班级</td>
      <td colspan="2">操作</td>
    </tr>
    <% 
              Teaching teaching= new Teaching();
		       ArrayList<Teaching> list= teaching.findAllTeaching();
		      	      for (Teaching x : list) {
		      %>
		       <tr align="center" class="teachingtr">	
		       <td align="center"><%=x.getId()   %></td>
               <td align="center"><%=x.getJname()%></td>	       
		       <td align="center"><%=x.getBanji() %></td>
		        <td align="center"><div>
<form action="${pageContext.request.contextPath }/servlet/TeachingContrllor?contrltype=1&teachingid=<%=x.getId()%>" method="post">
		       <input type="submit" class="btn btn-info btn-sm" id="delelet"value="删除"/>
</form>
		       </div></td>
		               <td align="center"><div>
<form action="${pageContext.request.contextPath }/servlet/TeachingContrllor?contrltype=2&teachingid=<%=x.getId()%>&Jname=<%=x.getJname()%>&banji=<%=x.getBanji() %>" method="post">
		       <input type="submit" class="btn btn-info btn-sm" value="提交修改"/>
</form>
		       </div></td>			</tr>
            <%} %>
    
    
    
  
  </table>
  
  </div>
  
  
  
  <!--插入弹出框-->
<div class="container">
	<div class="row clearfix">
		
			<div class="modal fade" id="modal-container-24928" role="dialog" aria-hidden="true" aria-labelledby="myModalLabel">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							 <button class="close" aria-hidden="true" type="button" data-dismiss="modal">×</button>
							<h4 class="modal-title" id="myModalLabel">
								添加任课信息
							</h4>
						</div>
						<div class="modal-body">
							<form id="formforaddQuestion" method="post"
                          action="${pageContext.request.contextPath }/servlet/QuestionContrllor?contrltype=3">
                          
                        <DIV class="info"><input type="text" name="jno" placeholder="任课教师编号"/></DIV>
                        <DIV class="info"><textarea placeholder="任课班级" name="banji"></textarea></DIV>
                        
                      <DIV class="span1 info"><input type="reset" value="取消" class="btn btn-default"  data-dismiss="modal" />&nbsp;&nbsp;
                      <input type="submit" value=" 提交" class="btn btn-primary" id="savainsert" onclick="addRow()" /></DIV>
                    </form>	 
						</div>
						
					</div>
				</div>
			</div>
		</div>
</div>   

<!--弹出框的功能-->
      <script>
	  
	 $(function(){
    $("#modal-24928").click(function(){
      $("#modal-container-24928").modal("toggle");
    });
  });   
 <!--删的功能--> 
     </script>
     <script type="text/javascript">
      $("#delelet").each( function() {$(this) .click( function() {
                                            this.parents(".teachingtr").remove();
                                        });

                    });

     
     var num = 0;
     function row(id){
         //构造函数
        this.id = $(id);
     }
     row.prototype = {
         //插入行
       
        
     }
    
     
     var inputItem; // 输入框句柄
    var activeItem; // 保存正在编辑的单元格
    
     //转成文本
    function changeToText(obj){
         if( obj && inputItem ) {
             // 如果存在正在编辑的单元格， 则取消编辑状态， 并将编辑的数据保存起来
            var str = " ";
             if(inputItem.value != "") 
                 str = inputItem.value;
             obj.innerText = str;   
         }
     }
     
     //转成编辑
    function changeToEdit(obj){
          if( !inputItem ) {
               inputItem = document.createElement('input');
               inputItem.type = 'text';
               inputItem.style.width = '100%';
          }
         // inputItem.style.display = '';
          inputItem.value = obj.innerText; // 将该单元格的数据文本读到控件上
         obj.innerHTML = ''; // 清空单元格的数据
         obj.appendChild(inputItem);
          inputItem.focus();
          activeItem = obj;
     }
     
     
     //双击时文本变成文本框
    document.ondblclick = function(){
         if(event.srcElement.tagName.toLowerCase() == "td"){
             if(!inputItem){
                 inputItem = document.createElement("input");
                 inputItem.type = "text";
                 inputItem.style.width = "100%";
             }
             changeToText();
             changeToEdit(event.srcElement);
         }else{
             event.returnValue = false;
             return false;
         }
     }
     
     //单击时文本框变成文本
    document.onclick = function(){
         if(event.srcElement.parentNode == activeItem || event.srcElement == activeItem)
             return;
         else
             changeToText(activeItem);
     }
     </script>
  <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
      <script src="https://code.jquery.com/jquery.js"></script>
      <!-- 包括所有已编译的插件 -->
      <script src="js/bootstrap.min.js"></script>
</body>
</html>
  
